/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tkatva.soalog.SoalogEjb.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author tuomas
 */
@Entity
@Table(name = "log_interface")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LogInterface.findAll", query = "SELECT l FROM LogInterface l")})
public class LogInterface implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "log_interface_id")
    private Integer logInterfaceId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "log_interface_name")
    private String logInterfaceName;
    @Size(max = 45)
    @Column(name = "log_interface_version")
    private String logInterfaceVersion;
    @Size(max = 1)
    @Column(name = "log_message_flag")
    private String logMessageFlag;
    @Size(max = 45)
    @Column(name = "environment_flag")
    private String environmentFlag;
    @Size(max = 100)
    @Column(name = "integration_type")
    private String integrationType;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "logInterfaceId")
    private List<InterfaceUserGroups> interfaceUserGroupsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "logInterfaceLogInterfaceId")
    private List<LogFields> logFieldsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "logInterfaceId")
    private List<LogEntry> logEntryList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "logInterfaceId")
    private List<LoginterfaceNotification> loginterfaceNotificationList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "logInterfaceLogInterfaceId")
    private List<LogSched> logSchedList;

    public LogInterface() {
    }

    public LogInterface(Integer logInterfaceId) {
        this.logInterfaceId = logInterfaceId;
    }

    public LogInterface(Integer logInterfaceId, String logInterfaceName) {
        this.logInterfaceId = logInterfaceId;
        this.logInterfaceName = logInterfaceName;
    }

    public Integer getLogInterfaceId() {
        return logInterfaceId;
    }

    public void setLogInterfaceId(Integer logInterfaceId) {
        this.logInterfaceId = logInterfaceId;
    }

    public String getLogInterfaceName() {
        return logInterfaceName;
    }

    public void setLogInterfaceName(String logInterfaceName) {
        this.logInterfaceName = logInterfaceName;
    }

    public String getLogInterfaceVersion() {
        return logInterfaceVersion;
    }

    public void setLogInterfaceVersion(String logInterfaceVersion) {
        this.logInterfaceVersion = logInterfaceVersion;
    }

    public String getLogMessageFlag() {
        return logMessageFlag;
    }

    public void setLogMessageFlag(String logMessageFlag) {
        this.logMessageFlag = logMessageFlag;
    }

    public String getEnvironmentFlag() {
        return environmentFlag;
    }

    public void setEnvironmentFlag(String environmentFlag) {
        this.environmentFlag = environmentFlag;
    }

    public String getIntegrationType() {
        return integrationType;
    }

    public void setIntegrationType(String integrationType) {
        this.integrationType = integrationType;
    }

    @XmlTransient
    public List<InterfaceUserGroups> getInterfaceUserGroupsList() {
        return interfaceUserGroupsList;
    }

    public void setInterfaceUserGroupsList(List<InterfaceUserGroups> interfaceUserGroupsList) {
        this.interfaceUserGroupsList = interfaceUserGroupsList;
    }

    @XmlTransient
    public List<LogFields> getLogFieldsList() {
        return logFieldsList;
    }

    public void setLogFieldsList(List<LogFields> logFieldsList) {
        this.logFieldsList = logFieldsList;
    }

    @XmlTransient
    public List<LogEntry> getLogEntryList() {
        return logEntryList;
    }

    public void setLogEntryList(List<LogEntry> logEntryList) {
        this.logEntryList = logEntryList;
    }

    @XmlTransient
    public List<LoginterfaceNotification> getLoginterfaceNotificationList() {
        return loginterfaceNotificationList;
    }

    public void setLoginterfaceNotificationList(List<LoginterfaceNotification> loginterfaceNotificationList) {
        this.loginterfaceNotificationList = loginterfaceNotificationList;
    }

    @XmlTransient
    public List<LogSched> getLogSchedList() {
        return logSchedList;
    }

    public void setLogSchedList(List<LogSched> logSchedList) {
        this.logSchedList = logSchedList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (logInterfaceId != null ? logInterfaceId.hashCode() : 0);
        return hash;
    }
    
     public LogEntry addLogEntry(LogEntry logEntry) {
        getLogEntryList().add(logEntry);
        logEntry.setLogInterfaceId(this);
        return logEntry;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LogInterface)) {
            return false;
        }
        LogInterface other = (LogInterface) object;
        if ((this.logInterfaceId == null && other.logInterfaceId != null) || (this.logInterfaceId != null && !this.logInterfaceId.equals(other.logInterfaceId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tkatva.soalog.SoalogEjb.entities.LogInterface[ logInterfaceId=" + logInterfaceId + " ]";
    }
    
}
